package com.springboot.erp.mapper;

import com.springboot.erp.entity.ExpenseDTO;
import com.springboot.erp.entity.JshAccountHead;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

@Mapper
public interface ExpenseMapper {
    ExpenseDTO selectExpenseById(@Param("id") Long id);
    List<JshAccountHead> selectExpenseList(
            @Param("organId") Long organId,
            @Param("status") String status,
            @Param("startDate") Date startDate,
            @Param("endDate") Date endDate
    );

    @Insert("insert into jsh_account_head(type, organ_id, hands_person_id," +
            " creator, change_amount, discount_money, total_price, account_id, " +
            "bill_no, bill_time, remark, file_name, status, source, tenant_id, delete_flag) " +
            "values ('支出', #{organId}, #{handsPersonId}, #{creator}, #{changeAmount}, " +
            "#{discountMoney}, #{totalPrice}, #{accountId}, #{billNo}, #{billTime}, #{remark}, " +
            "#{fileName}, #{status}, #{source}, #{tenantId}, #{deleteFlag})")
    void insertOne(JshAccountHead jshAccountHead);
    @Update("update jsh_account_head set  organ_id = #{organId}, hands_person_id = #{handsPersonId}," +
            "creator = #{creator}, change_amount = #{changeAmount}, discount_money = #{discountMoney}," +
            "total_price = #{totalPrice}, account_id = #{accountId}, bill_no = #{billNo}, bill_time = #{billTime}," +
            "remark = #{remark}, file_name = #{fileName}, status = #{status}, source = #{source}," +
            "tenant_id = #{tenantId}, delete_flag = #{deleteFlag} where id = #{id} and type = '支出'")
    void updateOne(JshAccountHead jshAccountHead);

    @Delete("delete from jsh_account_head where id = #{id} and type = '支出'")
    void deleteOne(@Param("id") Integer id);

}
